/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kifas.service;

import com.kifas.model.xml.PersistStatus;
import com.kifas.model.xml.StokOpnameModel;
import com.kifas.ui.util.ServiceConstants;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.WebResource;
import java.util.List;
import org.apache.log4j.Logger;

/**
 *
 * @author dhamarsu
 */
public class StokOpnameService {
    private static Logger log = Logger.getLogger(StokOpnameService.class);
    private String serviceUrl  = ServiceConstants.URL_CONTROLLER;
    private Client restClient;

    public StokOpnameService() {
        restClient = Client.create();
    }

    public List<StokOpnameModel> getAvailableBarang(Long idBarang){
        WebResource webResource = restClient.resource(serviceUrl + ServiceConstants.URL_AVAILABLE_STOK_BARANG + "/" + idBarang);
        return webResource.get(new GenericType<List<StokOpnameModel>>(){});
    }

    public List<StokOpnameModel> getAvailable(){
        WebResource webResource = restClient.resource(serviceUrl + ServiceConstants.URL_AVAILABLE);
        return webResource.get(new GenericType<List<StokOpnameModel>>(){});
    }

    public List<StokOpnameModel> getAvailableGudang(Long idGudang){
        WebResource webResource = restClient.resource(serviceUrl + ServiceConstants.URL_AVAILABLE_STOK_GUDANG + "/" + idGudang);
        return webResource.get(new GenericType<List<StokOpnameModel>>(){});
    }

    public PersistStatus getPopulateStok(){
        WebResource webResource = restClient.resource(serviceUrl + ServiceConstants.URL_STOK_POPULATE);
        return webResource.get(PersistStatus.class);
    }

}
